<%@ page language="java" import="java.util.*" import="java.sql.*" import = "orm.*"  pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base href = "<%=basePath%>" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Welcome-Online Test</title>
<link href="css/aStyles.css" rel="stylesheet" type="text/css" />
 <script type="text/javascript">
 <%if (request.getAttribute("success") != null){%>alert("<%=request.getAttribute("success")%>");<%request.removeAttribute("success");}
	else if (request.getAttribute("error") != null){%>alert("<%=request.getAttribute("error")%>");<%request.removeAttribute("error");}%>
function myFormCheck(theform)
{
   if(theform.theFile.value=="")
    {
       alert("请导入文件")
       theform.theFile.focus;
       return (false);
    }
    else
    {
       str= theform.theFile.value;
       strs=str.toLowerCase();
       lens=strs.length;
       extname=strs.substring(lens-4,lens);
       if(extname!=".xls")
       {
         alert("导入.xls文件")
         return (false);
       }
       else{
           return (true);
       }
    }
}

function manaAcc(name){
	
	var d = document.getElementById("mana");
	if (name.indexOf("stuMana") != -1){
		d.innerHTML = "<table width='300' border='1'  style='position:relative;top:70px;'><tr>"
        			+ "<td colspan='2' align='center'>学生管理</td></tr>"
                    + "<tr><form name='student_importForm' action='student_importAction.do' method='post'"
                    + "enctype='multipart/form-data' method='post' onsubmit='return myFormCheck(this)'>"
                    + "<td colspan='2'><input type='file' name='theFile' style='font-size:20px;width=250px;'/>"
                    + "</td><td><input type='submit' value='批量导入' name='importS'/></td></form></tr><tr>"
  					+ "<form name='stu_searchForm' method='post' action='stu_searchAction.do'><td colspan='2'>"
                    + "<input type='text' name='searchS' style='width: 230px; left: 13px; top: 148px;' /></td>"
    				+ "<td><input type='submit' value='查找' name='searchStu' /></td></form></tr>"
                	+ "<form name='modifyForm' action='modifyAction.do' method='post'><tr><td>用&nbsp;户&nbsp;名："
                	+ "</td><td><input type='text' name='student_name' value='<%=sname %>'/></td></tr>"
                  	+ "<tr><td>姓&nbsp;&nbsp;&nbsp;&nbsp;名：</td><td><input type='text' name='student_realname' "
                  	+ "value='<%=srealname%>' /></td></tr><tr><td> 电子邮箱：</td><td><input type='text' "
                  	+ "name='student_email' value='<%=semail %>'/></td></tr><tr><td>电话号码：</td>"
                    + "<td><input type='text' name='student_phone' value='<%=sphone %>'/></td><td>"
                    + "<input type='submit' name='modifyS' value='修改信息'  /></td></tr></form>"
                 	+ "<form name='delete_studentForm' method='post' action='delete_studentAction.do'/>"
                    + "<tr><td> 学生账号：</td><td><input type='text' name='student_id' value='<%=sid%>'/></td>"
                    + "<td><input type='submit' name='deleteS' value='删除学生'/></td></tr></form></table>";
	}
	else if(name.indexOf("teaMana") != -1){
		d.innerHTML = "<table width='300' border='1'  style='position:relative;top:70px;'><tr>"
        			+ "<td colspan='2' align='center'>老师管理</td></tr>"
                    + "<tr><form name='teacher_importForm' action='teacher_importAction.do' method='post'"
                    + "enctype='multipart/form-data' method='post' onsubmit='return myFormCheck(this)'>"
                    + "<td colspan='2'><input type='file' name='theFile' style='font-size:20px;width=250px;'/>"
                    + "</td><td><input type='submit' value='批量导入' name='importT'/></td></form></tr><tr>"
  					+ "<form name='tea_searchForm' method='post' action='tea_searchAction.do'><td colspan='2'>"
                    + "<input type='text' name='searchT' style='width: 230px; left: 13px; top: 148px;' /></td>"
    				+ "<td><input type='submit' value='查找' name='searchTea' /></td></form></tr>"
                	+ "<form name='modifyteahcerForm' action='modifyteacherAction.do' method='post'><tr><td>用&nbsp;户&nbsp;名："
                	+ "</td><td><input type='text' name='teacher_name' value='<%=tname %>'/></td></tr>"
                  	+ "<tr><td>姓&nbsp;&nbsp;&nbsp;&nbsp;名：</td><td><input type='text' name='teacher_realname' "
                  	+ "value='<%=trealname%>' /></td></tr><tr><td> 电子邮箱：</td><td><input type='text' "
                  	+ "name='teacher_email' value='<%=temail %>'/></td></tr><tr><td>电话号码：</td>"
                    + "<td><input type='text' name='teacher_phone' value='<%=tphone %>'/></td><td>"
                    + "<input type='submit' name='modifyT' value='修改信息'  /></td></tr></form>"
                 	+ "<form name='delete_teacherForm' method='post' action='delete_teacherAction.do'/>"
                    + "<tr><td> 老师账号：</td><td><input type='text' name='teacher_id' value='<%=tid%>'/></td>"
                    + "<td><input type='submit' name='deleteT' value='删除老师'/></td></tr></form></table>";
	}
}
</script>
</head>
<%!
String sname = null,srealname = null,semail=null,sphone=null;
long sid = 0;
long tid = 0;
String tname = null,trealname = null,temail = null,tphone = null;
%>

<%User stu = null; 
User tea = null;
if(request.getAttribute("student") != null){
	stu = (User)request.getAttribute("student");
	sname = stu.getUsername();
	srealname = stu.getRealname();
	semail = stu.getEmail();
	sphone = stu.getPhone();
	sid = stu.getUserid();
	request.removeAttribute("student");
}

if(request.getAttribute("teacher") != null){
	tea = (User)request.getAttribute("teacher");
	tname = tea.getUsername();
	trealname = tea.getRealname();
	temail = tea.getEmail();
	tphone = tea.getPhone();
	tid = tea.getUserid();
	request.removeAttribute("teacher");
}
 %>

<body>
<!-- CONTAINER START -->
<div id = "container">
	<!-- HEADER START -->
        <div id = "top">
        	<div id = "navigation">
            	<html:link page="/admi/admi.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;首页</html:link>
                <html:link page="/admi/notice.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;通知</html:link>
                <html:link page="/admi/accMan.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;帐户管理</html:link>
                <html:link page="/admi/message.jsp" styleClass = "link">&nbsp;&nbsp;&nbsp;&nbsp;留言板管理</html:link>
            </div>
        </div>
        <!-- HEADER END -->
        
   	<!-- LOGIN START -->
        <div id = "login">
        	<html:link page="" styleClass="viewTest">·查看当前考试</html:link>
          	<p><html:link page="/admi/admModifyPwd.jsp" styleClass="modifyPwd">·修改密码</html:link></p>
            <p><html:link forward="logout" styleClass="logout">·注销登录</html:link></p>
  </div>
        <!-- LOGIN END -->
        
        <!-- CLOCK START -->
  <div id = "clock">
        	<iframe src="index/clock.html" height="407" width="296" frameborder="0" scrolling="no"
            		marginheight="0" marginwidth="0" id="clockFrame" name="clockFrame"></iframe>
</div>
        <!-- CLOCK END -->
        
        <!-- MAIN START -->
      	<div id = "main">
      		<center>
      		<table style="position:relative;top:50px;"><tr><td>
      		<input type="button" name="stuMana" value="学生管理" onclick="manaAcc(this.name)"/></td>
      		<td><input type="button" name="teaMana" value="老师管理" onclick="manaAcc(this.name)"/></td></tr></table>
      		<div id="mana"><%if (stu != null){%>
        	<table width="300" border="1"  style="position:relative;top:70px;"><tr>
        			<td colspan="2" align="center">学生管理</td></tr>
                    <tr><form name="student_importForm" action="student_importAction.do" method="post"
                    	enctype="multipart/form-data" method="post" onsubmit="return myFormCheck(this)">
                    	<td colspan="2"><input type="file" name="theFile" style="font-size:20px;width=250px;"/>
                            </td>
                            <td><input type="submit" value="批量导入" name="importS"/></td>
                        </form>
 					</tr>
  					<tr>
  					<form name="stu_searchForm" method="post" action="stu_searchAction.do">
    					<td colspan="2">
                        <input type="text" name="searchS" style="width: 230px; left: 13px; top: 148px;" /></td>
    					<td><input type="submit" value="查找" name="searchStu" /></td>
    				</form>
  					</tr>
                
                	<form name="modifyForm" action="modifyAction.do" method="post">
               	  <tr><td>用&nbsp;户&nbsp;名：</td>
                       <td><input type="text" name="student_name" value="<%=sname %>"/>
                    </td></tr>
                  
                  <tr><td>姓&nbsp;&nbsp;&nbsp;&nbsp;名：</td>
                       <td><input type="text" name="student_realname" value="<%=srealname%>" />
                    </td>
                  </tr>
                  
                  <tr><td> 电子邮箱：</td>
                       <td><input type="text" name="student_email" value="<%=semail %>"/>
                    </td>
                  </tr>
                  <tr><td>电话号码：</td>
                       <td><input type="text" name="student_phone" value="<%=sphone %>"/>
                    </td>
                    <td>
                    	<input type="submit" name="modifyS" value="修改信息"  />
                    </td>
                    </tr>
                   </form>
                 <form name="delete_studentForm" method="post" action="delete_studentAction.do"/>
                        <tr><td> 学生账号：</td>
                       <td><input type="text" name="student_id" value="<%=sid%>"/></td>
                        <td><input type="submit" name="deleteS" value="删除学生"/></td>
                  </tr></form></table><%}else if (tea != null){ %>
                  
                  <table width="300" border="1"  style="position:relative;top:70px;"><tr>
        			<td colspan="2" align="center">老师管理</td></tr>
                    <tr><form name="teacher_importForm" action="teacher_importAction.do" method="post"
                    	enctype="multipart/form-data" method="post" onsubmit="return myFormCheck(this)">
                    	<td colspan="2"><input type="file" name="theFile" style="font-size:20px;width=250px;"/>
                            </td>
                            <td><input type="submit" value="批量导入" name="importT"/></td>
                        </form>
 					</tr>
  					<tr>
  					<form name="tea_searchForm" method="post" action="tea_searchAction.do">
    					<td colspan="2">
                        <input type="text" name="searchT" style="width: 230px; left: 13px; top: 148px;" /></td>
    					<td><input type="submit" value="查找" name="searchTea" /></td>
    				</form>
  					</tr>
                
                	<form name="modifyteacherForm" action="modifyteacherAction.do" method="post">
               	  <tr><td>用&nbsp;户&nbsp;名：</td>
                       <td><input type="text" name="teacher_name" value="<%=tname %>"/>
                    </td></tr>
                  
                  <tr><td>姓&nbsp;&nbsp;&nbsp;&nbsp;名：</td>
                       <td><input type="text" name="teacher_realname" value="<%=trealname%>" />
                    </td>
                  </tr>
                  
                  <tr><td> 电子邮箱：</td>
                       <td><input type="text" name="teacher_email" value="<%=temail %>"/>
                    </td>
                  </tr>
                  <tr><td>电话号码：</td>
                       <td><input type="text" name="teacher_phone" value="<%=tphone %>"/>
                    </td>
                    <td>
                    	<input type="submit" name="modifyT" value="修改信息"  />
                    </td>
                    </tr>
                   </form>
                 <form name="delete_teacherForm" method="post" action="delete_teacherAction.do"/>
                        <tr><td> 老师账号：</td>
                       <td><input type="text" name="teacher_id" value="<%=tid%>"/></td>
                        <td><input type="submit" name="deleteT" value="删除老师"/></td>
                  </tr></form></table>
                  <%} %>
                  </div>
              </center>
        </div>
				<%
				srealname = null;
				semail=null;
				sphone=null;
				sname=null;
				sid = 0;
				tid = 0;
				
				tname=null;
				trealname = null;
				temail = null;
				tphone = null;
				%>
	<!-- MAIN END -->
        
	<!-- FOOTER START -->
	<div id = "footer">
  </div>
	<!-- FOOTER END -->
        
  </div>
    <!-- CONTAINER END -->
    
</body>
</html>
